.class public Lrexsee/multimedia/RexseeAudioCapture;
.super Ljava/lang/Object;
.source "RexseeAudioCapture.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# static fields
.field public static final EVENT_ONAUDIOCAPTUREINFO:Ljava/lang/String; = "onAudioCaptureInfo"

.field private static final INTERFACE_NAME:Ljava/lang/String; = "AudioCapture"


# instance fields
.field private final mBrowser:Lrexsee/core/browser/Browser;

.field private final mCaptureArguments:Lrexsee/multimedia/MediaCaptureArguments;

.field public final mContext:Landroid/content/Context;

.field private final mErrorListener:Landroid/media/MediaRecorder$OnErrorListener;

.field private final mInfoListener:Landroid/media/MediaRecorder$OnInfoListener;

.field private recorder:Landroid/media/MediaRecorder;


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 2
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 60
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 32
    const/4 v0, 0x0

    iput-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->recorder:Landroid/media/MediaRecorder;

    .line 34
    new-instance v0, Lrexsee/multimedia/RexseeAudioCapture$1;

    invoke-direct {v0, p0}, Lrexsee/multimedia/RexseeAudioCapture$1;-><init>(Lrexsee/multimedia/RexseeAudioCapture;)V

    iput-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->mErrorListener:Landroid/media/MediaRecorder$OnErrorListener;

    .line 40
    new-instance v0, Lrexsee/multimedia/RexseeAudioCapture$2;

    invoke-direct {v0, p0}, Lrexsee/multimedia/RexseeAudioCapture$2;-><init>(Lrexsee/multimedia/RexseeAudioCapture;)V

    iput-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->mInfoListener:Landroid/media/MediaRecorder$OnInfoListener;

    .line 61
    iput-object p1, p0, Lrexsee/multimedia/RexseeAudioCapture;->mBrowser:Lrexsee/core/browser/Browser;

    .line 62
    invoke-virtual {p1}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->mContext:Landroid/content/Context;

    .line 63
    new-instance v0, Lrexsee/multimedia/MediaCaptureArguments;

    invoke-direct {v0}, Lrexsee/multimedia/MediaCaptureArguments;-><init>()V

    iput-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->mCaptureArguments:Lrexsee/multimedia/MediaCaptureArguments;

    .line 64
    iget-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    const-string v1, "onAudioCaptureInfo"

    invoke-virtual {v0, v1}, Lrexsee/core/browser/clazz/EventList;->add(Ljava/lang/String;)V

    .line 65
    return-void
.end method

.method static synthetic access$0(Lrexsee/multimedia/RexseeAudioCapture;)Lrexsee/core/browser/Browser;
    .locals 1

    .prologue
    .line 30
    iget-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->mBrowser:Lrexsee/core/browser/Browser;

    return-object v0
.end method


# virtual methods
.method public getArguments()Ljava/lang/String;
    .locals 2

    .prologue
    .line 99
    iget-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->mCaptureArguments:Lrexsee/multimedia/MediaCaptureArguments;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Lrexsee/multimedia/MediaCaptureArguments;->toString(Z)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 20
    return-object p0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 16
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioCapture;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "AudioCapture"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getNewInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 1
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 24
    new-instance v0, Lrexsee/multimedia/RexseeAudioCapture;

    invoke-direct {v0, p1}, Lrexsee/multimedia/RexseeAudioCapture;-><init>(Lrexsee/core/browser/Browser;)V

    return-object v0
.end method

.method public setArguments(Ljava/lang/String;)V
    .locals 1
    .param p1, "argu"    # Ljava/lang/String;

    .prologue
    .line 102
    iget-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->mCaptureArguments:Lrexsee/multimedia/MediaCaptureArguments;

    invoke-virtual {v0, p1}, Lrexsee/multimedia/MediaCaptureArguments;->parseArguments(Ljava/lang/String;)Lrexsee/multimedia/MediaCaptureArguments;

    .line 103
    return-void
.end method

.method public start(Ljava/lang/String;)Z
    .locals 8
    .param p1, "path"    # Ljava/lang/String;

    .prologue
    const/4 v7, 0x0

    .line 70
    invoke-static {p1}, Lrexsee/core/utilities/Utilities;->prepareWriteFile(Ljava/lang/String;)Ljava/io/File;

    move-result-object v1

    .line 71
    .local v1, "target":Ljava/io/File;
    if-nez v1, :cond_0

    .line 72
    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioCapture;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/multimedia/RexseeAudioCapture;->getInterfaceName()Ljava/lang/String;

    move-result-object v3

    const-string v4, "Invalid target file path."

    invoke-virtual {v2, v3, v4}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move v2, v7

    .line 84
    :goto_0
    return v2

    .line 75
    :cond_0
    invoke-virtual {p0}, Lrexsee/multimedia/RexseeAudioCapture;->stop()Z

    .line 77
    :try_start_0
    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioCapture;->mCaptureArguments:Lrexsee/multimedia/MediaCaptureArguments;

    const/4 v3, 0x0

    const/4 v4, 0x0

    iget-object v5, p0, Lrexsee/multimedia/RexseeAudioCapture;->mErrorListener:Landroid/media/MediaRecorder$OnErrorListener;

    iget-object v6, p0, Lrexsee/multimedia/RexseeAudioCapture;->mInfoListener:Landroid/media/MediaRecorder$OnInfoListener;

    invoke-virtual {v2, v3, v4, v5, v6}, Lrexsee/multimedia/MediaCaptureArguments;->getRecorder(Landroid/hardware/Camera;Landroid/view/SurfaceHolder;Landroid/media/MediaRecorder$OnErrorListener;Landroid/media/MediaRecorder$OnInfoListener;)Landroid/media/MediaRecorder;

    move-result-object v2

    iput-object v2, p0, Lrexsee/multimedia/RexseeAudioCapture;->recorder:Landroid/media/MediaRecorder;

    .line 78
    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioCapture;->recorder:Landroid/media/MediaRecorder;

    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/media/MediaRecorder;->setOutputFile(Ljava/lang/String;)V

    .line 79
    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioCapture;->recorder:Landroid/media/MediaRecorder;

    invoke-virtual {v2}, Landroid/media/MediaRecorder;->prepare()V

    .line 80
    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioCapture;->recorder:Landroid/media/MediaRecorder;

    invoke-virtual {v2}, Landroid/media/MediaRecorder;->start()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 81
    const/4 v2, 0x1

    goto :goto_0

    .line 82
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 83
    .local v0, "e":Ljava/lang/Exception;
    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioCapture;->mBrowser:Lrexsee/core/browser/Browser;

    if-eqz v2, :cond_1

    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioCapture;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/multimedia/RexseeAudioCapture;->getInterfaceName()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3, v0}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    :cond_1
    move v2, v7

    .line 84
    goto :goto_0
.end method

.method public stop()Z
    .locals 1

    .prologue
    .line 88
    iget-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->recorder:Landroid/media/MediaRecorder;

    if-eqz v0, :cond_0

    .line 90
    :try_start_0
    iget-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->recorder:Landroid/media/MediaRecorder;

    invoke-virtual {v0}, Landroid/media/MediaRecorder;->stop()V

    .line 91
    iget-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->recorder:Landroid/media/MediaRecorder;

    invoke-virtual {v0}, Landroid/media/MediaRecorder;->release()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 94
    :goto_0
    const/4 v0, 0x0

    iput-object v0, p0, Lrexsee/multimedia/RexseeAudioCapture;->recorder:Landroid/media/MediaRecorder;

    .line 96
    :cond_0
    const/4 v0, 0x1

    return v0

    .line 92
    :catch_0
    move-exception v0

    goto :goto_0
.end method
